var currentIndexTemp = 0;
var indexTemp = 0;
efform_onload = function ()
{ 
	$('#ef_tab_y').hide();
	efgrid.submitInqu( "ef_grid_r", "ZM","ZMCN40","query");
//	efgrid_onRowClicked("ef_grid_r",0);
}; 

button_query_onclick = function () 
{   	
	efgrid.submitInqu( "ef_grid_r", "ZM","ZMCN40","query");
}
button_update_onclick = function (){ 
	if (isSelected("ef_grid_r") == 0)return; 
	//以下是行增，无校验
//	efgrid.submitForm( "ef_grid_r", "ZM","ZMCN40","update",true);
	//以下是行增，有校验
	var info = getSCZXEiInfos("ZMCN40","ef_grid_r");//ZMCN40 为EFFORM id，ef_grid_r为grid id（paintId）
	if (null != info) { 
		EiCommunicator.send("ZMCN40", "validate1", info, validate1_callback);
	}
}
button_insert_onclick = function (){
	if (isSelected("ef_grid_r") == 0)return; 
//	efgrid.submitForm( "ef_grid_r", "ZM","ZMCN40","insert",true);
	var info = getSCZXEiInfos("ZMCN40","ef_grid_r");
	if (null != info) { 
		EiCommunicator.send("ZMCN40", "validate", info, validate_callback);
	}
} 
button_delete_onclick = function (){
	var grid=isSelected("ef_grid_r");
	if (grid == 0)return; 
	EFConfirm('你确认要删除吗?', '确认框', function(r) {
		if(r){
			//efgrid.submitForm( "ef_grid_r", "ZM","ZMCN40","delete",true);
			var info = getSCZXEiInfos("ZMCN40","ef_grid_r");
			if (null != info) { 
				EiCommunicator.send("ZMCN40", "validate1", info, validate1_callback);
			}
		}
		
	}); 
}

efgrid_onRowClicked = function( grid_id, row_index ){
	if(grid_id == "ef_grid_r"){
		$('#ef_tab_y').show();
		var grid = efgrid.getGridObject(grid_id);
		year=grid.getCellValueByColumnName(row_index,"fdYear");
		month=grid.getCellValueByColumnName(row_index,"fdMonth");
		$("#inqu_status-0-year").val(year);
		$("#inqu_status-0-month").val(month);
//		EiCommunicator.send("ZMCN41", "query", info, ajax_callback); 
		fundiv(currentIndexTemp,indexTemp);
	}
}
var validate_callback={
		onSuccess:function(eiInfo){
			if(eiInfo.getStatus()==-1){
				EFAlert("操作失败，原因："+eiInfo.getMsg());
			}else{
				var oper="insert";
				if(eiInfo.get("efCurButtonEname")=="UPDATE"){
					oper="update";
				}
				efgrid.submitForm( "ef_grid_r", "ZM","ZMCN40",oper,true);

			}
		},
		onFail:function(eMsg)
		{
			EFAlert("操作失败，原因："+eMsg); 
		}
}
var validate_detail_callback={
		onSuccess:function(eiInfo){
			if(eiInfo.getStatus()==-1){
				EFAlert("操作失败，原因："+eiInfo.getMsg());
			}else{
				 efwindow.hide();
				 var grid = efgrid.getGridObject("ef_grid_d");
				 grid.refresh(eiInfo);
			}
		},
		onFail:function(eMsg)
		{
			EFAlert("操作失败，原因："+eMsg); 
		}
}
var validate1_callback={
		onSuccess:function(eiInfo){
			if(eiInfo.getStatus()==-1){
				EFAlert("操作失败，原因："+eiInfo.getMsg());
			}else{
				var oper="delete";
				if(eiInfo.get("efCurButtonEname")=="UPDATE"){
					//进行重复性校验
					oper="update";
					EiCommunicator.send("ZMCN40", "validate", eiInfo, validate_callback);
				}else{
					efgrid.submitForm( "ef_grid_r", "ZM","ZMCN40","delete",true);
				}
			}
		},
		onFail:function(eMsg)
		{
			EFAlert("操作失败，原因："+eMsg); 
		}
	}
/********************************************************************************
 ***********************************页签操作**************************************** 
 ********************************************************************************/
function fundiv(currentIndex,index){ 
	currentIndexTemp = currentIndex;
	indexTemp = index;
    var year=$("#inqu_status-0-year").val();
	var month=$("#inqu_status-0-month").val();
	if(index ==0)
	{  
		var frame = frames[0];
		frame.src = "DispatchAction.do?efFormEname=ZMCN41"+"&year="+year+"&month="+month;
		efform.setStatus(0, "正在加载...");
	}else if(index ==1)
	{ 
		var frame = frames[1];
		frame.src = "DispatchAction.do?efFormEname=ZMCN42"+"&year="+year+"&month="+month;
		efform.setStatus(0, "正在加载...");
	}else if(index ==2)
	{ 
		var frame = frames[2];
		frame.src = "DispatchAction.do?efFormEname=ZMCN43"+"&year="+year+"&month="+month;
		efform.setStatus(0, "正在加载...");
	}else if(index ==3)
	{ 
		var frame = frames[3];
		frame.src = "DispatchAction.do?efFormEname=ZMCN44"+"&year="+year+"&month="+month;
		efform.setStatus(0, "正在加载...");
	}else if(index ==4)
	{ 
		var frame = frames[4];
		frame.src = "DispatchAction.do?efFormEname=ZMCN45"+"&year="+year+"&month="+month;
		efform.setStatus(0, "正在加载...");
	}else if(index ==5)
	{ 
		var frame = frames[5];
		frame.src = "DispatchAction.do?efFormEname=ZMCN46"+"&year="+year+"&month="+month;
		efform.setStatus(0, "正在加载...");
	}else if(index ==6)
	{ 
		var frame = frames[6];
		frame.src = "DispatchAction.do?efFormEname=ZMCN47"+"&year="+year+"&month="+month;
		efform.setStatus(0, "正在加载...");
	}else if(index ==7)
	{ 
		var frame = frames[7];
		frame.src = "DispatchAction.do?efFormEname=ZMCN49"+"&year="+year+"&month="+month;
		efform.setStatus(0, "正在加载...");
	}else if(index ==8)
	{ 
		var frame = frames[8];
		frame.src = "DispatchAction.do?efFormEname=ZMCN4A"+"&year="+year+"&month="+month;
		efform.setStatus(0, "正在加载...");
	}else if(index ==9)
	{ 
		var frame = frames[9];
		frame.src = "DispatchAction.do?efFormEname=ZMCN48"+"&year="+year+"&month="+month;
		efform.setStatus(0, "正在加载...");
	}         
}

